import axios from 'axios';
import { loginReqUrl } from '../config/httpConfig';
import { requestBegin, requestEnd } from './actionCommon';
export const LOGIN = 'LOGIN';
export const LOGIN_OPERATE = 'LOGIN_OPERATE';
axios.defaults.withCredentials = true;
export function login (loginData) {
    return (dispatch) => {
        dispatch(requestBegin('sFetching'));
        return axios.post(loginReqUrl, loginData)
            .then((res) => {
                dispatch(loginOperate({
                    info: res,
                }));
                dispatch(requestEnd('success'));
            })
            .catch(err => {
                if (err) {
                    dispatch(requestEnd(err));
                }
            });
    };
}
export function loginOperate (data) {
    return {
        type: LOGIN_OPERATE,
        loginData: data.info,
    };
}
